package com.cyz.api.imagesearch;

import com.cyz.api.imagesearch.model.ImageSearchResult;
import com.cyz.api.imagesearch.sub.GetImageFirstUrlApi;
import com.cyz.api.imagesearch.sub.GetImageList;
import com.cyz.api.imagesearch.sub.GetImagePageUrlApi;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class ImageSearchApiFacade {


    /**
     * 以图搜图
     * @param imageUrl  图片 url
     * @return  搜索结果列表
     */
    public static List<ImageSearchResult> searchImages(String imageUrl){
        String imagePageUrl = GetImagePageUrlApi.getImagePageUrl(imageUrl);
        String imageFirstApi = GetImageFirstUrlApi.getImageFirstApi(imagePageUrl);
        return GetImageList.getImageList(imageFirstApi);
    }

    public static void main(String[] args) {
        List<ImageSearchResult> imageSearchResults = searchImages("https://beifeng-1368922749.cos.ap-beijing.myqcloud.com/space/1946899528809046018/2025-07-21_RffiYevdzGZYZHub.webp");
        System.out.println(imageSearchResults);
    }

}
